<?
//------ BEGIN PROGRAM ------//

include"hubung.php";

// periksan input data
	if($codem==""||$trans==""||$saldo==""||$note==""||$codet==""){
	header ('Location: ../main');
	exit;
	}

// memindai tanggal!!!
	$date=date("d M Y");

// lakukan pencarian!!
	$baca=mysql_query("select * from saldo where codem ='$codem'");
	$cari=mysql_num_rows($baca);

// algoritm laksanakan
	if($cari==0){
	/* data baru */
	$new=mysql_query("insert into saldo (date,codem,trans,saldo,note,codet)values('$date','$codem','$trans', '$saldo', '$note', '$codet')");
	}
	else{
	/* updt data */
	$upd=mysql_query("update saldo set date='$date', trans='$trans', saldo='$saldo', note='$note', codet='$codet' where codem='$codem'");
	}

// kembalikan kemenu!!
	header ('Location: ../main');

//------ ENDING PROGRAM ------//
?>